<template>
  <div class="login">
    <el-card class="box-card" center>
      <div slot="header" class="clearfix">
        <span>后台管理系统</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text"
          >操作按钮</el-button
        > -->
      </div>
      <div class="text item">
        <el-form ref="form" :rules="rule" :model="form" label-width="70px">
          <el-form-item prop="userName" label="用户名">
            <el-input v-model="form.userName"></el-input>
          </el-form-item>
          <el-form-item prop="password" label="密码">
            <el-input v-model="form.password" show-password></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              @click="jump"
              type="primary"
              size="large"
              style="width: 100%"
              >登录</el-button
            >
          </el-form-item>
        </el-form>
        <div style="color: red">PS:直接点击登录即可...</div>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        userName: "admin",
        password: "123456789",
      },
      rule: {
        userName: [
          { required: true, message: "请填写用户名", trigger: "blur" },
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },
  methods: {
    jump() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$message({
            type:'success',
            message:'登录成功'
          })
          this.$router.push({path:'/'})
          localStorage.setItem('userName',this.form.userName)
          localStorage.setItem('password',this.form.password)
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>

<style scoped>
.login {
  width: 100%;
  height: 100%;
  background-image: url("../../imags/timg.png");
  padding: 180px 0;
  box-sizing: border-box;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 400px;
  margin: auto;
  text-align: center;
  cursor: pointer;
  opacity: 0.7;
  background: blanchedalmond;
}
/deep/.el-card__body {
  padding: 20px 30px 30px 10px;
}
</style>